const app = getApp()
let qCloud = require("../../../index.js");
Page({

    /**
     * 页面的初始数据
     */
    data: {
        imgPath: qCloud.config.STATIC_IMAGE_PATH,
        userList: [],
    },

    radioChange(e) {
        let items = this.data.userList
        let value = e.detail.value
        for (let i = 0, lenI = items.length; i < lenI; ++i) {
           if (items[i].userId == value) {
               wx.setStorageSync("weapp_choose_user", {
                   userId: items[i].userId,
                   realName: items[i].realName,
                   phone: items[i].phone
               });
              break;
           }
        }
    },

    doSubmit() {
        wx.navigateBack({
            delta: 1
        })
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.getMyOrganUserList();
    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {
        this.getMyOrganUserList();
    },

    getMyOrganUserList: function () {
        let self = this;
        app.fetchApis(self, qCloud.api.getMyOrganUserList, {}, "GET", function (e) {
            if (e.data.code == 200) {
                self.setData({
                    userList: e.data.data
                })
            }
        })
    }
})
